source('~/Desktop/origin_inequality/Supplementary Material/Figures/energy_firm_power.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/energy_firm_power.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/energy_firm_power.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/energy_firm_power.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/energy_firm_power.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/energy_firm_power.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/energy_firm_power.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/energy_firm_power.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/energy_firm_power.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/energy_firm_power.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/energy_firm_power.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/energy_firm_power.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/energy_firm_power.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/energy_firm_power.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/energy_firm_power.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/energy_firm_power.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/energy_firm_power.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/energy_firm_power.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/energy_firm_power.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/energy_firm_power.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/energy_firm_power.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/case_pay_shape.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/case_pay_shape.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/case_shape.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/case_pay_shape.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/case_shape.R')
library(ggplot2)
library(gridExtra)
library(data.table)
library(hmod)
library(magrittr)
library(scales)
library(here)
text.size = 10
dir = here()
wd = gsub("Figures", "Hierarchy Model/results", dir)
setwd(wd)
mod = fread("power_concentration.csv")
names(mod) = c("firm_size", "power_gini")
wd = gsub("Figures", "Empirical Data/GEM", dir)
setwd(wd)
setwd(wd)
energy = fread("energy_v_firm.csv")
source('~/Desktop/origin_inequality/Supplementary Material/Figures/power_concentration.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/power_concentration.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/lenski_plot.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/lenski_plot.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/lenski_plot.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/lenski_plot.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/lenski_plot.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/lenski_plot.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/lenski_plot.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/power_concentration.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/mod_landscape_growth.R')
n = 10000
alpha = 2.1
large_firm_sample = rpld(10^7, 1, alpha, 2.3*10^4)
high_mean_firm = mean(large_firm_sample)
high_energy = e_predict(high_mean_firm) %>% round()
high_energy_label = paste(  "Industrial Society \nEnergy Use per Capita ~ ", high_energy, "GJ per person")
firm_sim = sample(large_firm_sample, n)
base_sim = base_fit(a, b, firm_sim)
r_sim = r_sim_2(fit$V1, fit$r, firm_sim)
base_pay_sim = bp_sim(fit$base_pay, n)
mod_high = model(a, b, base_sim, firm_sim, base_pay_sim, r_sim, sigma, power = T) %>% data.table()
high_power_gini = fastgini(mod_high$power)
high_power_gini = fastgini(mod_high$power) %>% round(.,2)
source('~/Desktop/origin_inequality/Supplementary Material/Figures/mod_landscape_growth.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/mod_landscape_growth.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/mod_landscape_growth.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/mod_landscape_growth.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/mod_landscape_growth.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/mod_landscape_growth.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/mod_landscape_growth.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/mod_landscape_growth.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/mod_landscape_growth.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/mod_landscape_growth.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/mod_landscape_growth.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/mod_landscape_growth.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/mod_landscape_growth.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/mod_landscape_growth.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/mod_landscape_growth.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/mod_landscape_growth.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/mod_landscape_growth.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/mod_landscape_growth.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/mod_landscape_growth.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/mod_landscape_growth.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/mod_landscape_growth.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/mod_landscape_growth.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/mod_landscape_growth.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/mod_landscape_growth.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/mod_landscape_growth.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/mod_landscape_growth.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/mod_landscape_growth.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/mod_landscape_growth.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/mod_landscape_growth.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/mod_landscape_growth.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/mod_landscape_growth.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/mod_landscape_growth.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/mod_landscape_growth.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/mod_landscape_growth.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/mod_landscape_growth.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/mod_landscape_growth.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/mod_landscape_growth.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/mod_landscape_growth.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/mod_landscape_growth.R')
high_energy = e_predict(high_mean_firm)
high_energy = round(high_energy/100) * 100
source('~/Desktop/origin_inequality/Supplementary Material/Figures/mod_landscape_growth.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/mod_landscape_growth.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/mod_landscape_growth.R')
firm_sim = sample(large_firm_sample, 10^6)
base_sim = base_fit(a, b, firm_sim)
r_sim = r_sim_2(fit$V1, fit$r, firm_sim)
base_pay_sim = bp_sim(fit$base_pay,10^6)
mod_high = model(a, b, base_sim, firm_sim, base_pay_sim, r_sim, sigma, power = T) %>% data.table()
high_power_gini = fastgini(mod_high$power) %>% round(.,2)
source('~/Desktop/origin_inequality/Supplementary Material/Figures/mod_landscape_growth.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/mod_landscape_growth.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/mod_landscape_growth.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/mod_landscape_growth.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/mod_landscape_growth.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/mod_landscape_growth.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/mod_landscape_growth.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/mod_landscape_growth.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/mod_landscape_growth.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/mod_landscape_growth.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/mod_hierarchy_shape.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/mod_hierarchy_shape.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/mod_hierarchy_shape.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/mod_hierarchy_shape.R')
power = c(1,1,2)
g = Gini(g)
source('~/Desktop/origin_inequality/Supplementary Material/Figures/power_gini_example.R')
g = Gini(power)
?Gini
g = Gini(power, corr = T)
power = c(1,1,3)
g = Gini(power, corr = T)
power = c(rep(1, 4), 3, 3, 7)
g = Gini(power, corr = T)
power = c(rep(1, 8), rep(3, 4) , 7, 7, 15)
g = Gini(power, corr = T)
power = c(rep(1, 16), rep(3, 8), rep(7, 4) , 15, 15, 31)
g = Gini(power, corr = T)
power = c(1,1,3)
g = Gini(power, corr = T)
power = c(1,1,3)
rep(power, 10^4)
powe = rep(power, 10^4)
g = Gini(power, corr = T)
power = c(1,1,3)
power = rep(power, 10^4)
g = Gini(power, corr = T)
power = c(1,1,3)
g = Gini(power, corr = T)
power = c(1,1,3)
g = Gini(power)
power = c(1,1,3)
power = rep(power, 10^4)
g = Gini(power)
power = c(rep(1, 4), 3, 3, 7)
g = Gini(power)
power = c(rep(1, 4), 3, 3, 7)
g = Gini(power)
power = c(rep(1, 8), rep(3, 4) , 7, 7, 15)
g = Gini(power)
power = c(rep(1, 16), rep(3, 8), rep(7, 4) , 15, 15, 31)
g = Gini(power)
power = c(1,1,3)
power = rep(power, 10^4)
g = Gini(power)
power = c(rep(1, 4), 3, 3, 7)
g = Gini(power)
power = c(rep(1, 8), rep(3, 4) , 7, 7, 15)
g = Gini(power)
power = c(rep(1, 16), rep(3, 8), rep(7, 4) , 15, 15, 31)
g = Gini(power)
power = c(rep(1, 32), rep(3, 16), rep(7, 8), rep(15, 4), 31, 31, 63)
g = Gini(power)
source('~/Desktop/origin_inequality/Supplementary Material/Figures/power_gini_example.R')
hist(power)
library(ggplot2)
library(readr)
library(gridExtra)
library(grid)
library(gtable)
library(data.table)
library(hmod)
library(snow)
library(doSNOW)
library(foreach)
library(tcltk)
library(here)
n.iteration = 10000
dir = here()
wd = gsub("Figures", "Hierarchy Model/data", dir)
setwd(wd)
s = fread("s_empirical.txt")
g = fread("g_empirical.txt")
source('~/Desktop/origin_inequality/Supplementary Material/Figures/case_parameters.R')
library(ggplot2)
library(gridExtra)
library(data.table)
library(hmod)
library(magrittr)
library(scales)
library(here)
text.size = 10
dir = here()
wd = gsub("Figures", "Hierarchy Model/results", dir)
setwd(wd)
mod = fread("power_concentration.csv")
names(mod) = c("firm_size", "power_gini", "pay_gini")
wd = gsub("Figures", "Empirical Data/GEM", dir)
setwd(wd)
energy = fread("energy_v_firm.csv")
x = log(energy$energy)
y = log(energy$firm_mean)
r = lm(y ~ x)
a = exp(coef(r)[1])
b = coef(r)[2]
e_predict = function(x){
y = (x/a)^(1/b)
return(y)
}
energy_predict = e_predict(mod$firm_size)
mod$energy = energy_predict
source('~/Desktop/origin_inequality/Supplementary Material/Figures/pay_concentration_test.R')
gini
source('~/Desktop/origin_inequality/Supplementary Material/Figures/pay_concentration_test.R')
gini
source('~/Desktop/origin_inequality/Supplementary Material/Figures/pay_concentration_test.R')
gini
source('~/Desktop/origin_inequality/Supplementary Material/Figures/pay_concentration_test.R')
gini
source('~/Desktop/origin_inequality/Supplementary Material/Figures/pay_concentration_test.R')
gini
source('~/Desktop/origin_inequality/Supplementary Material/Figures/pay_concentration_test.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/pay_concentration_test.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/pay_concentration_test.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/pay_concentration_test.R')
summary(mod$pay_exponent)
source('~/Desktop/origin_inequality/Supplementary Material/Figures/pay_concentration_test.R')
0.000004186798*365*20000
0.000004186798*365*17000
eastern_1000_bce = 0.000004186798*365*17000
eastern_1000_bce = 0.000004186798*365*17000
eastern_1500_ce = 0.000004186798*365*30000
source('~/Desktop/origin_inequality/Supplementary Material/Figures/pay_concentration_test.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/pay_concentration_test.R')
0.000004186798*365*4000
kcal_to_gj = 0.000004186798
hunter_gatherer_min = kcal_to_gj*365*2000
source('~/Desktop/origin_inequality/Supplementary Material/Figures/pay_concentration_test.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/pay_concentration_test.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/pay_concentration_test.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/pay_concentration_test.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/pay_concentration_test.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/pay_concentration_test.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/pay_concentration_test.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/pay_concentration_test.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/pay_concentration_test.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/pay_concentration_test.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/pay_concentration_test.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/pay_concentration_test.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/pay_concentration_test.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/pay_concentration_test.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/pay_concentration_test.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/pay_concentration_test.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/pay_concentration_test.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/pay_concentration_test.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/pay_concentration_test.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/pay_concentration_test.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/pay_concentration_test.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/pay_concentration_test.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/pay_concentration_test.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/pay_concentration_test.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/pay_concentration_test.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/pay_concentration_test.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/pay_concentration_test.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/pay_concentration_test.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/pay_concentration_test.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/pay_concentration_test.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/pay_concentration_test.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/pay_concentration_test.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/pay_concentration_test.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/pay_concentration_test.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/pay_concentration_test.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/pay_concentration_test.R')
geo_mean = function(x,y){
exp(mean(log(c(x,y))))
}
source('~/Desktop/origin_inequality/Supplementary Material/Figures/pay_concentration_test.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/pay_concentration_test.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/pay_concentration_test.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/pay_concentration_test.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/pay_concentration_test.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/pay_concentration_test.R')
US_min = 133
US_max = 379
source('~/Desktop/origin_inequality/Supplementary Material/Figures/pay_concentration_test.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/pay_concentration_test.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/pay_concentration_test.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/pay_concentration_test.R')
source('~/Desktop/origin_inequality/Supplementary Material/Figures/income_v_power_firm.R')
get_alpha = function(power, income){
r = lm(log(income) ~ log(power))
alpha = coef(r)[2]
return(alpha)
}
View(result)
get_alpha(result$N.sub, result$P.norm)
test = result[, get_alpha(N.sub, P.norm), by = Source]
View(test)
source('~/Desktop/origin_inequality/Supplementary Material/Figures/income_v_power_firm.R')
View(result)
source('~/Desktop/origin_inequality/Supplementary Material/Figures/income_v_power_firm.R')
View(result)
View(firm_alpha)
View(firm_alpha)
source('~/Desktop/origin_inequality/Supplementary Material/Figures/pay_concentration.R')
source_name = unique(result$Source)
firm = subset(result, Source = source_name[1] )
View(firm)
source_name = unique(result$Source)
firm = subset(result, Source == source_name[1] )
boot(data= firm, statistic = get_alpha,  R=1000, formula = log(P.norm) ~log(N.sub))
boot(data= firm, statistic = get_alpha,  R=1000, formula = P.norm ~ N.sub)
library(ggplot2)
library(boot)
library(magrittr)
library(data.table)
library(dplyr)
library(grid)
library(ineq)
library(here)
text.size = 10
dir = here()
wd = gsub("Figures", "Empirical Data/Case Studies/Number of Subordinates", dir)
setwd(wd)
result = fread("Subordinates Results.csv")
# subfunction to get coeff from lm bootstrap
coeff <- function(data, indices){
d <- data[indices,] # allows boot to select sample
fit <- fastLmPure( cbind( rep.int(1, length(d[, 1])), log(d[, 1]) ),
log(d[, 2] )
)
return(coef(fit)[2])
}
boot.coef = boot(data = x, statistic = coeff, R = n, parallel="multicore", ncpus = detectCores()    )
library(ggplot2)
library(parallel)
boot.coef = boot(data = x, statistic = coeff, R = n, parallel="multicore", ncpus = detectCores()    )
data = dataltable(result$N.sub, result$P.norm)
data = data.table(result$N.sub, result$P.norm)
test = coeff(data, 1:nrow(data))
data = cbind(result$N.sub, result$P.norm)
test = coeff(data, 1:nrow(data))
x = cbind(result$N.sub, result$P.norm)
n = 1000
boot.coef = boot(data = x, statistic = coeff, R = n, parallel="multicore", ncpus = detectCores()    )
boot.regression = boot(data = x, statistic = coeff, R = n, parallel="multicore", ncpus = detectCores()    )
beta = boot.regression$t
hist(beta)
bootstrap = function(x, n){
# subfunction to get coefficient from lm bootstrap
coeff <- function(data, indices){
d <- data[indices,] # allows boot to select sample
fit <- fastLmPure( cbind( rep.int(1, length(d[, 1])), log(d[, 1]) ),   log(d[, 2] )  )
return(coef(fit)[2])
}
# bootstrap linear regression of span vs level
boot.regression = boot(data = x, statistic = coeff, R = n, parallel="multicore", ncpus = detectCores()    )
beta = boot.regression$t
return(beta)
}
bootstrap(x, n)
test = bootstrap(x, n)
hist(test)
hist(test, breaks = 100)
bootstrap = function(power, income,  n){
x = cbind(power, income)
# subfunction to get coefficient from lm bootstrap
coeff <- function(data, indices){
d <- data[indices,] # allows boot to select sample
fit <- fastLmPure( cbind( rep.int(1, length(d[, 1])), log(d[, 1]) ),   log(d[, 2] )  )
return(coef(fit)[2])
}
# bootstrap linear regression of span vs level
boot.regression = boot(data = x, statistic = coeff, R = n, parallel="multicore", ncpus = detectCores()    )
beta = boot.regression$t
return(beta)
}
n_boot = 10^4
test = result[, bootstrap(N.sub, P.norm)]
test = result[, bootstrap(N.sub, P.norm, n_boot), by = Source]
View(test)
beta_boot = result[, bootstrap(N.sub, P.norm, n_boot), by = Source]
beta_boot = result[, (beta = bootstrap(N.sub, P.norm, n_boot)), by = Source]
g = ggplot() +
geom_density(data = beta_boot, aes(beta, fill = Source))
g
beta_boot = result[, .(beta = bootstrap(N.sub, P.norm, n_boot)), by = Source]
beta_boot = result[, bootstrap(N.sub, P.norm, n_boot), by = Source]
g = ggplot() +
geom_density(data = beta_boot, aes(V1, fill = Source))
g
g = ggplot() +
geom_density(data = beta_boot, aes(V1, fill = Source), alpha = 0.3)
g
g = ggplot() +
geom_density(data = beta_boot, aes(V1, fill = Source), alpha = 0.3) +
coord_cartesian(ylim = c(0, 50))
g
source('~/Desktop/origin_inequality/Supplementary Material/Figures/income_v_power_firm.R')
g
View(beta_boot)
beta_boot = beta_boot[V! != 0]
beta_boot = beta_boot[V1 != 0]
g = ggplot() +
geom_density(data = beta_boot, aes(V1, fill = Source), alpha = 0.3)
g
g = ggplot() +
geom_density(data = beta_boot, aes(V1, fill = Source), alpha = 0.3, adjust = 2)
g
g = ggplot() +
geom_density(data = beta_boot, aes(V1, fill = Source), alpha = 0.3, adjust = 3)
g
coord_cartesian(xlim = c(00.2, 0.7))
g
g = ggplot() +
geom_density(data = beta_boot, aes(V1, fill = Source), alpha = 0.3, adjust = 3) +
coord_cartesian(xlim = c(00.2, 0.7))
g
g = ggplot() +
geom_density(data = beta_boot, aes(V1, fill = Source), alpha = 0.3, adjust = 3) +
coord_cartesian(xlim = c(0.15, 0.7))
g
g = ggplot() +
geom_density(data = beta_boot, aes(V1, fill = Source), alpha = 0.3, adjust = 2) +
coord_cartesian(xlim = c(0.15, 0.7))
g
g = ggplot() +
geom_density(data = beta_boot, aes(V1, fill = Source), alpha = 0.3, adjust = 1) +
coord_cartesian(xlim = c(0.15, 0.7))
g
View(result)
conf = function(x){
q = quantile(x, probs = c(0.025, 0.975))
}
test = conf(beta_boot$V1)
conf_interval = conf(beta_boot$V1)
g = ggplot() +
geom_density(data = beta_boot, aes(V1, fill = Source), alpha = 0.3, adjust = 1) +
geom_vline(xintercept = conf_interval[1], linetype = 2) +
coord_cartesian(xlim = c(0.15, 0.7))
g
g = ggplot() +
geom_vline(xintercept = conf_interval[1], linetype = 2) +
geom_vline(xintercept = conf_interval[2], linetype = 2) +
geom_density(data = beta_boot, aes(V1, fill = Source), alpha = 0.3, adjust = 1) +
coord_cartesian(xlim = c(0.15, 0.7))
g
g = ggplot() +
geom_vline(xintercept = conf_interval[1], linetype = 2, col = "grey50") +
geom_vline(xintercept = conf_interval[2], linetype = 2) +
geom_density(data = beta_boot, aes(V1, fill = Source), alpha = 0.3, adjust = 1) +
coord_cartesian(xlim = c(0.15, 0.7))
g
g = ggplot() +
geom_vline(xintercept = conf_interval[1], linetype = 2, col = "grey50") +
geom_vline(xintercept = conf_interval[2], linetype = 2, col = "grey50")) +
geom_density(data = beta_boot, aes(V1, fill = Source), alpha = 0.3, adjust = 1) +
coord_cartesian(xlim = c(0.15, 0.7))
g = ggplot() +
geom_vline(xintercept = conf_interval[1], linetype = 2, col = "grey50") +
geom_vline(xintercept = conf_interval[2], linetype = 2, col = "grey50") +
geom_density(data = beta_boot, aes(V1, fill = Source), alpha = 0.3, adjust = 1) +
coord_cartesian(xlim = c(0.15, 0.7))
g
beta_boot = result[, bootstrap(N.sub, P.norm, n_boot), by = Source]
g = ggplot() +
geom_vline(xintercept = conf_interval[1], linetype = 2, col = "grey50") +
geom_vline(xintercept = conf_interval[2], linetype = 2, col = "grey50") +
geom_density(data = beta_boot, aes(V1, fill = Source), alpha = 0.3, adjust = 2) +
coord_cartesian(xlim = c(0.15, 0.7))
g
source('~/Desktop/origin_inequality/Supplementary Material/Figures/pay_concentration.R')
wd = gsub("Figures", "Hierarchy Model/data", dir)
setwd(wd)
conf_interval = conf(beta_boot$V1) %>% data.table()
View(conf_interval)
fwrite(conf_interval, "power_to_pay_exponent.csv")
source('~/Desktop/origin_inequality/Supplementary Material/Hierarchy Model/data/data_format.R')
workspace = gsub("Hierarchy Model/data",  "Emperical Data/Case Studies", dir)
setwd(workspace)
d = fread("Case Results.csv")
workspace = gsub("Hierarchy Model/data",  "Empirical Data/Case Studies", dir)
setwd(workspace)
d = fread("Case Results.csv")
# write data for hierarchy model
wd = gsub("Figures", "Hierarchy Model/data", dir)
setwd(wd)
fwrite(conf_interval, "power_to_pay_exponent.txt", col_names = F)
library(read)
library(readr)
wd = gsub("Figures", "Hierarchy Model/data", dir)
setwd(wd)
write_tsv(conf_interval, "power_to_pay_exponent.txt", col_names = F)
source('~/Desktop/origin_inequality/Supplementary Material/Figures/income_v_power_firm.R')
source('~/Desktop/origin_inequality/Supplementary Material/Hierarchy Model/data/data_format.R')
